#pragma once

#include <QObject>
#include <QHash>
#include <QList>
#include <memory>
#include "park_point.h"
#include "kernel/interfaces/ILogger.h"

namespace application {
namespace park {

/**
 * @brief 停车点管理器
 * @details 管理单个楼层的所有停车点
 */
class ParkManager : public QObject {
    Q_OBJECT

public:
    explicit ParkManager(int floor, std::shared_ptr<kernel::ILogger> logger = nullptr, QObject* parent = nullptr);
    ~ParkManager() = default;

    // 停车点管理
    void addParkPoint(std::shared_ptr<ParkPoint> parkPoint);
    void removeParkPoint(const QString& pointId);
    std::shared_ptr<ParkPoint> getParkPoint(const QString& pointId) const;

    // 查询
    bool hasParkPoint(const QString& pointId) const;
    QList<QString> getAllParkPointIds() const;
    int getFloor() const { return m_floor; }

    // 查找可用停车点
    std::shared_ptr<ParkPoint> findAvailableParkPoint() const;
    QList<std::shared_ptr<ParkPoint>> getAvailableParkPoints() const;

    // 初始化
    void initializeParkPoints();

signals:
    void parkPointAdded(const QString& pointId);
    void parkPointRemoved(const QString& pointId);
    void parkPointAvailabilityChanged(const QString& pointId, bool available);

private:
    int m_floor;
    QHash<QString, std::shared_ptr<ParkPoint>> m_parkPoints;
    std::shared_ptr<kernel::ILogger> m_logger;
};

} // namespace park
} // namespace application
